package com.libre.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.libre.auth.entity.RolePermission;
import com.libre.auth.mapper.RolePermissionMapper;
import com.libre.auth.service.RolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @description   用户角色
* @author        庞留杰
* @date          2022/01/01 17:46
* @version       V1.0
**/
@Slf4j
@Service
@Transactional
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {

    @Override
    public List<RolePermission> findListByRoleId(RolePermission rolePermission) {
        QueryWrapper<RolePermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete","0");
        queryWrapper.eq("role_id",rolePermission.getRoleId());
        List<RolePermission> list = this.list(queryWrapper);
        return list;
    }

    @Override
    public Boolean save(List<RolePermission> rolePermissions) {
        //删除

        //添加
        boolean b = this.saveBatch(rolePermissions);
        return b;
    }

}
